home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998…eptember: Technology Seed / September 98 ADC Seed CD.toast / Language Analysis Manager / DarumaDR1Package / Examples / DictionaryAccess / Sources / Main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  2.9 KB  |  114 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        Main.c
  3.     
  4.     Contains:    A Sample application for dictionary access.
  5.  
  6.      Version:    Technology:    System 8
  7.                  Release:    Daruma Developer Release 1
  8.  
  9.      Copyright:    1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Contact:    daruma@apple.com
  12.  
  13. */
  14.  
  15.  
  16. #include "DictionaryAccess.h"
  17. #include "FunctionProto.h"
  18.  
  19. #include <Menus.h>
  20. #include <Resources.h>
  21. #include <Dialogs.h>
  22. #include <Fonts.h>
  23. #include <AppleEvents.h>
  24. #include <Appearance.h>
  25. #include <TextServices.h>
  26.  
  27. // ========================================================================================
  28. // Prototypes for static functions
  29. // ========================================================================================
  30. static void Initialize ( void );
  31. static void SetUpMenus ( void );
  32. static OSStatus InstallAppleEventHandlers( void );
  33.  
  34.  
  35. // ========================================================================================
  36. // main
  37. // ========================================================================================
  38. void main ( void )
  39. {
  40.     Initialize();
  41.     MainEventLoop();
  42. }
  43.  
  44.  
  45. // ========================================================================================
  46. // Initialize
  47. // ========================================================================================
  48. static void Initialize ( void )
  49. {
  50.     //------------------------------------------------------------------------------
  51.     // Initialize Toolbox
  52.     //
  53.     InitGraf( (Ptr)&qd.thePort);
  54.     InitFonts();
  55.     FlushEvents( everyEvent, 0);
  56.     InitWindows();
  57.     InitMenus();
  58.     TEInit();
  59.     InitDialogs( nil);
  60.     InitCursor();
  61.     InitTSMAwareApplication();
  62.     RegisterAppearanceClient();
  63.  
  64.     //------------------------------------------------------------------------------
  65.     // Initialize application part
  66.     //
  67.     SetUpMenus();
  68.     InstallAppleEventHandlers();
  69. }
  70.  
  71.  
  72. // ========================================================================================
  73. // SetUpMenus
  74. // ========================================================================================
  75. static void SetUpMenus ( void )
  76. {
  77.     Handle            menuBar;
  78.     UInt16            i;
  79.     
  80.     menuBar = GetNewMBar( kMenuBarResID);
  81.     SetMenuBar( menuBar);
  82.     
  83.     AppendResMenu( GetMenuHandle( kAppleMenuID), 'DRVR');
  84.  
  85.     //------------------------------------------------------------------------------
  86.     // Pre-load all popup menus because the menu which loaded at creating popup menu
  87.     // is disposed on DisposeDialog. This can be a problem on multi window application.
  88.     //
  89.     for ( i = kFirstPopupMenuID; i <= kLastPopupMenuID; i++ )
  90.     {
  91.         InsertMenu( GetMenu( i), hierMenu);
  92.     }
  93.     
  94.     DrawMenuBar();
  95. }
  96.  
  97.  
  98. // ========================================================================================
  99. // InstallAppleEventHandlers
  100. // ========================================================================================
  101.  
  102. static OSStatus InstallAppleEventHandlers( void )
  103. {
  104.     OSStatus    err;
  105.     
  106.     err = AEInstallEventHandler( kCoreEventClass, kAEQuitApplication,
  107.                                  NewAEEventHandlerProc( AEQuitHandler), 0, false);
  108.     
  109.     return err;
  110. }
  111.  
  112.  
  113.  
  114.